﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AvantGameMachine.Graphics
{
    public class Material
    {
        Texture texture = null;
        private PosVector[] vertex = null;
        private Color[] color = null;

        public Material(int _vertex, Texture _text)
        {
            texture = _text;
            vertex = new PosVector[_vertex];
            color = new Color[_vertex];
            SetAllColors(Color.White());
        }

        public Material(Texture _text):this(4,_text)
        {
            // The default mode.
            vertex[0] = new PosVector(1.0f, 1.0f, 0);
            vertex[1] = new PosVector(1.0f, 0, 0);
            vertex[2] = new PosVector(0, 0, 0);
            vertex[3] = new PosVector(0, 1.0f, 0);
        }

        public void SetAllColors(Color c)
        {
            for (int i = 0; i < color.Length; i++)
                color[i] = c;
        }

        public Color GetColor(int _index)
        {
            return color[_index];
        }

        public void SetColor(int _index, Color _c)
        {
            color[_index] = _c;
        }

        public Texture MapTexture
        {
            get { return texture;  }
            set { texture = value; }
        }

        public void SetVertex(int _nv, PosVector _vertex)
        {
            vertex[_nv] = _vertex;
        }

        public PosVector GetVertex(int _nv)
        {
            return vertex[_nv];
        }
    }
}
